package secretary;

import java.sql.SQLException;

import javax.swing.JFrame;

import secretaryGUI.createSecretaryWindow;
import secretaryGUI.secretaryAlerts;

import com.sun.rowset.CachedRowSetImpl;

import basic.ClientConsole;
import flexibility.userData;
import gui.secretaryScreen;
import guiCode.secretaryScreenCode;

public class changeClassName {
	secretaryAlerts sa = new secretaryAlerts();
	private userData userChanges = new userData();
	
	public void setChanges(createSecretaryWindow csw, secretaryScreenCode ssc,JFrame secretaryScreen,int code, int type, String change, String id, String semester, ClientConsole con){
		CachedRowSetImpl crs;
		try {
			crs = new CachedRowSetImpl();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		userChanges.deleteAll();//check if there already class with that name in this semester
		userChanges.addData(13);
		userChanges.addData(1);
		userChanges.addData(change);
		userChanges.addData(semester);
		con.acceptMsg(userChanges);
		crs = con.getResults();
		try {
			if(crs.next()==true){
				sa.showMessages(csw, ssc, csw.secretaryScreen,"This class already exist in database!", "Create new class - failure", 1);
			}
			else{
				
				
				userChanges.deleteAll();
				userChanges.addData(code);//class does not exist in database
				userChanges.addData(type);
				userChanges.addData(change);
				userChanges.addData(id);
				userChanges.addData(semester);
				con.acceptMsg(userChanges);
				con.getResults();
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
